<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFileTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('files', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title')->comment('资源名称');
            $table->integer('product_id')->commnet('关联产品id');
            $table->integer('resource_id')->comment('资源类别id');
            $table->integer('category_id')->comment('类别id');
            $table->enum('source', ['local', 'external'])->comment('资源来源， local本地、external外部');
            $table->string('local')->nullable()->comment('本地链接');
            $table->string('external')->nullable()->comment('外部链接');
            $table->enum('cost', ['free', 'charge'])->default('free')->comment('费用， free免费， charge收费');
            $table->integer('price')->default(0)->comment('价格');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('files');
    }
}
